import type { RouteRecordRaw } from 'vue-router';
/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      hidden：        是否隐藏此路由
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 静态路由（默认路由）
 */
export const staticRoutes: Array<RouteRecordRaw> = [
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login/index.vue'),
        meta: {
            hidden: true,
        },
    },

    {
        path: '/404',
        name: '404',
        component: () => import('@/views/error/404.vue'),
        meta: {
            hidden: true,
        },
    },

    {
        path: '/',
        component: () => import('@/layout/index.vue'),
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'Home',
                component: () => import('@/views/home/index.vue'),
                meta: {
                    title: '首页',
                    icon: 'ele-HomeFilled',
                },
            },
        ],
    },
];

/**
 * 定义动态路由
 */
export const allAsyncRoutes: Array<RouteRecordRaw> = [
    /* 权限管理路由 start */
    {
        path: '/acl',
        name: 'acl',
        component: () => import('@/layout/index.vue'),
        redirect: '/acl/user/list',
        meta: {
            title: '权限管理',
            icon: 'ele-Setting',
        },
        children: [
            {
                name: 'user',
                path: '/acl/user/list',
                component: () => import('@/views/acl/user/index.vue'),
                meta: {
                    title: '用户管理',
                },
            },
            {
                name: 'role',
                path: '/acl/role/list',
                component: () => import('@/views/acl/role/index.vue'),
                meta: {
                    title: '角色管理',
                },
            },
            {
                name: 'roleauth',
                path: '/acl/role/auth',
                component: () => import('@/views/acl/role/roleAuth.vue'),
                meta: {
                    title: '角色管理',
                    hidden: true,
                    activeMenu: '/acl/role/list',
                },
            },
            {
                name: 'permission',
                path: '/acl/permission/list',
                component: () => import('@/views/acl/permission/index.vue'),
                meta: {
                    title: '菜单管理',
                },
            },
        ],
    },
    /* 权限管理路由 end */
    {
        path: '/product',
        name: 'product',
        component: () => import('@/layout/index.vue'),
        meta: {
            title: '商品管理',
            icon: 'ele-MessageBox',
        },
        children: [
            {
                path: 'trademark/list',
                name: 'trademark',
                component: () => import('@/views/Trademark/index.vue'),
                meta: {
                    title: '品牌管理',
                },
            },
            {
                path: 'attr/list',
                name: 'attr',
                component: () => import('@/views/Attr/index.vue'),
                meta: {
                    title: '平台属性管理',
                },
            },
            {
                path: 'sku/list',
                name: 'sku',
                component: () => import('@/views/Sku/index.vue'),
                meta: {
                    title: 'Sku管理',
                },
            },
            {
                path: 'spu/list',
                name: 'spu',
                component: () => import('@/views/Spu/index.vue'),
                meta: {
                    title: 'Spu管理',
                },
            },
        ],
    },
];

// 任意路由
export const anyRoute: RouteRecordRaw =
    /* 匹配任意的路由 必须最后注册 */
    {
        path: '/:pathMatch(.*)',
        name: 'Any',
        redirect: '/404',
        meta: {
            hidden: true,
        },
    };
